import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsArray, IsDateString, IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';

export class MainPlanItemDto {
  @ApiProperty({ description: '班级ID' })
  @IsString()
  @IsNotEmpty()
  classId: string;

  @ApiProperty({ description: '主计划名称' })
  @IsString()
  @IsNotEmpty()
  planName: string;

  @ApiProperty({ description: '子计划列表，多个子计划用-分隔，例如: "阅读-写作-口语"' })
  @IsString()
  @IsNotEmpty()
  subPlans: string;

  @ApiProperty({ description: '打卡开始时间，不提供则默认使用班级开班时间', required: false })
  @IsDateString()
  @IsOptional()
  punchStartAt?: string;

  @ApiProperty({ description: '计划备注', required: false })
  @IsString()
  @IsOptional()
  mark?: string;
}

export class CreateMainPlanDto {
  @ApiProperty({ description: '主计划列表', type: [MainPlanItemDto] })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => MainPlanItemDto)
  plans: MainPlanItemDto[];
}
